<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr= [{name:"tom"},{name:"jack"}];
        /* array,object,string,boolean,number */
        function deepClone(obj){
            /* 如果是初始化值，则直接返回 */
            
            let result;
            if(obj instanceof Array){
                result =[]
            }else if(typeof obj =="object"){
                result = {}
            }
            else{
                return obj
            }
            for(let key in obj ){
                result[key]=deepClone(obj[key])
            }
            return result
        }
        var newArr=deepClone(arr)
        arr[0].name="react"
        console.log(newArr);
    </script>
</body>
</html>